package String;

public class StringStringBuilderDemo {
    public static void main(String[] args) {
        String str = "好好学习Java";
        //赋值str的内容到builder
        StringBuilder builders = new StringBuilder(str);
        //append（）追加内容--在末尾追加
        builders.append(".为了找工作");
        System.out.println(builders);
        //replace（）：替换部分内容（包左不包右）
        builders.replace(9,16,"就是为了改变世界");
        System.out.println(builders);
        //delete（）：删除部分内容（包左不包右）
        builders.delete(0,8);
        System.out.println(builders);
        //insert（）：插入内容
        builders.insert(0,"活着");
        System.out.println(builders);

//        // StringBuilder的创建方式
//        StringBuilder builder = new StringBuilder();
//        StringBuilder builder1 = new StringBuilder("abc");
//        //String和 StringBuilder互转
//        String string = "abc";
//        StringBuilder builder2  =new StringBuilder(string);
//        String string2 = builder2.toString();
//        System.out.println(string2);
    }

}
